package com.bds.btcdc.web.action;

import com.bds.btcdc.web.model.StrategyOneArgs;
import com.bds.btcdc.web.service.StrategyOneService;
import com.bds.btcdc.web.utils.CookieUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: kevin
 * @date: 2018/5/2
 * @description: 对冲交易Controller
 */
@Controller
public class DCTradeAction {
	Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private StrategyOneService strategyOneService;


	@RequestMapping("/dc/dchand")
	public String dcHand() {
		logger.info("--------------------------跳转到现货交易页面------------------------");
		return "ftl/dc/hand_dc_trade";
	}

	@RequestMapping("/dc/setting")
	public String strategy_args(HttpServletRequest request, Model model) {
		logger.info("--------------------------跳转到策略参数设置------------------------");
		Long user_id = CookieUtils.getUserIdfromCookie(request);
		StrategyOneArgs args = strategyOneService.getOneByUserId(user_id);
		if(args==null){
			args=new StrategyOneArgs();
		}
		model.addAttribute("args",args);
		return "ftl/user/strategy_args";
	}


}
